package ming.util.base;

import java.util.ResourceBundle;


/**
 * 项目参数工具类
 * 
 */
public class ConfigUtil {

	private static final ResourceBundle bundle = java.util.ResourceBundle.getBundle("config");

	/**
	 * 获得sessionInfo名字
	 * 
	 * @return
	 */
	public static final String getSessionInfoName() {
		return bundle.getString("sessionInfoName");
	}

	/**
	 * 通过键获取值
	 * 
	 * @param key
	 * @return
	 */
	public static final String get(String key) {
		if(bundle.containsKey(key)){
			return bundle.getString(key);
		}else {
			return "";
		}
	}
	
	/**
	 * 通过键获取值,设置默认值
	 * 
	 * @param key
	 * @return
	 */
	public static final String get(String key,String defaultValue) {
		if(bundle.containsKey(key)){
			return bundle.getString(key);
		}else {
			return defaultValue;
		}
	}

	public static final String i18nGet(String key){
		try {
			ResourceBundle myResourcesCN = ResourceBundle.getBundle("string-"+get("language"));
			return new String(myResourcesCN.getString(key).getBytes("iso-8859-1"),"utf-8");
		}catch (Exception e){
			return "";
		}
	}

}
